package com.study.samsung.Control.htControl;

import com.study.samsung.Service.DetailService;
import com.study.samsung.Utils.BaseServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;

@WebServlet("/goodsxqedit")
public class GoodsxqEditServlet extends BaseServlet {
    DetailService ds = new DetailService();

    @Override
    public String excute(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.setCharacterEncoding("utf-8");
        Object obj = session.getAttribute("admin");
        if (obj==null){
            return "f:htjsp/login";
        }else {
            String xprice = request.getParameter("xprice");
            Integer sxid = Integer.parseInt(request.getParameter("sxid"));
            session.setAttribute("xprice",xprice);
            session.setAttribute("sxid",sxid);
            return "f:/htjsp/goodsxqedit";
        }

    }

    public Integer changeprice(HttpServletRequest request, HttpServletResponse response) throws Exception {
        request.setCharacterEncoding("utf-8");
        String Sxid = request.getParameter("sid");
        String Price = request.getParameter("price");
        System.out.println("修改的ajax传过来的sid==="+Sxid);
        System.out.println("修改的ajax传过来的price==="+Price);
        Integer sxid = Integer.parseInt(Sxid);
        Double price = Double.parseDouble(Price);

        Integer integer = ds.changePrice(sxid, price);
        if (integer>0){
            return 1;
        }else {
            return 0;
        }

    }
}
